<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

	<head>
		<title>Gimme Sibling and Ancestor Tests</title>

		<script type = "text/javascript" src = "../jsunit/app/jsUnitCore.js"></script>
		<script type = "text/javascript" src = "../utils/jsunit/jsUnitHelperFunctions.js"></script>
		<script type = "text/javascript" src = "../build/debug/gimme.js"></script>
		
		<script type = "text/javascript">
			function test_getGrandparentOfPanda3()
			{
				var gObj = g(this.get('panda3'));
				var grandParent = gObj.getAncestor(2);
				assertEquals('The retrieved "grandParent" is not document.body', document.body, grandParent);
			}
			
			function test_getZeroDistanceAncestor()
			{
				var gObj = g(this.get('forest'));
				var same = gObj.getAncestor(0);
				assertEquals('The underyling Gimme object element and the variable, same, are not equal', gObj.element(), same);
			}
			
			function test_getNegativeDistanceAncestor()
			{
				var gObj = g(this.get('forest'));
				var same = gObj.getAncestor(-4);
				assertEquals('The underyling Gimme object element and the variable, same, are not equal', gObj.element(), same);
			}
			
			function test_getFirstNextSiblingOfZoo()
			{
				var gObj = g(this.get('zoo'));
				var firstSib = gObj.getSibling(1);
				assertEquals('The retrieved first next sibling of #zoo is not #forest', firstSib, this.get('forest'));
			}
			
			function test_getSecondNextSiblingOfTiger1()
			{
				var gObj = g(this.get('tiger1'));
				var secondSib = gObj.getSibling(2);
				assertEquals('The retrieved second next sibling of #tiger1 is not #panda3', secondSib, this.get('panda3'));
			}
			
			function test_getThirdPreviousSiblingOfIvyPlant1()
			{
				var gObj = g(this.get('ivyPlant1'));
				var thirdSib = gObj.getSibling(-3);
				assertEquals('The retrieved third previous sibling of #ivyPlant1 is not #tree2', thirdSib, this.get('tree2'));
			}		

		</script>
	</head>

	<body>
		<h1>Gimme Sibling and Ancestor Tests</h1>

		<div id = "zoo" class = "place man-made">
			<span id = "panda1" class = "panda">Panda1</span>
			<span id = "tiger1" class = "tiger">Tiger1</span>
			<span id = "panda2" class = "panda">Panda2</span>
			<span id = "panda3" class = "panda" foo = "bar">Panda2</span>
		</div>
		<div id = "forest" class = "place natural">
			<p id = "tree1" class = "tree pine">Pine tree 1</p>
			<p id = "tree2" class = "tree oak">Oak tree 1</p>
			<span id = "chipmunk1" class = "mammal chipmunk">Chipmunk 1</span>
			<span id = "gazelle1" class = "mammal gazelle">Gazelle 1</span>
			<p id = "ivyPlant1" class = "ivy poison">Poison Ivy Plant 1</p>
		</div>
	</body>

</html>